<template>
  <div>
    <a-select
      @change="handleChange"
      show-search
      placeholder="请选择用户"
      :disabled="disabled"
      :filter-option="filterOption"
      mode="multiple"
      v-model="curValue"
    >
      <a-select-option v-for="item in dataSource" :key="item.Id + '-' + item.RealName">
        {{ item.RealName }}
      </a-select-option>
    </a-select>
  </div>
</template>

<script>
export default {
  props: {
    value: { require: false, type: Array },
    disabled: { require: false, type: Boolean, default: false },
  },
  data () {
    return {
      dataSource: [],
      curValue: [],
    }
  },
  watch: {
    value (n) {
      this.curValue = n
    }
  },
  mounted () {
    this.getDataList()
  },
  methods: {
    handleChange (e) {
      this.$emit('input', e)
    },
    getDataList () {
      this.$http
        .post('/Base_Manage/Base_User/GetDataList', {
          PageIndex: 1,
          PageRows: 9999,
          SortField: 'Id',
          SortType: 'desc',
          Search: {},
        })
        .then((resJson) => {
          this.dataSource = resJson.Data
        })
    },
    filterOption (input, option) {
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    }
  },
}
</script>

<style>
</style>